﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QLLUONG.BLL;
namespace QLLUONG
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }
        UserBLL UBLL = new UserBLL();

        private void button1_Click(object sender, EventArgs e)
        {
            Login();
        }
        public void Login()
        {
            String Username = txtUser.Text;
            String Pass = txtPass.Text;
            bool KT = UBLL.Kiemtra(Username, Pass);
            if (KT == true)
            {
                MessageBox.Show("Bạn đã đăng nhập thành công");
                Form1 FrmMain = new Form1();
                this.Hide();
                FrmMain.Show();
            }
            else
            {
                MessageBox.Show("Bạn đã nhập sai Username hoặc password");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult h = MessageBox.Show
                ("Bạn có chắc muốn thoát không?", "Error", MessageBoxButtons.OKCancel);
            if (h == DialogResult.OK)
                Application.Exit(); 
        }

        private void FormLogin_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                MessageBox.Show("Pass");
            }
        }

        private void txtUser_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                Login();
            }
        }

        private void txtPass_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                Login();
            }
        }
    }
}